package com.base.common.utils;

import java.math.BigInteger;
import java.security.MessageDigest;

public class Md5Salt {

    private final static String SALT = "salt";

    private static byte[] toMD5(byte[] input) {
        MessageDigest md;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        md.update(input);
        return md.digest();
    }

    public static String getMD5(String password) {
        try {
            byte[] r = Md5Salt.toMD5((SALT + password).getBytes("UTF-8"));
            return String.format("%032x", new BigInteger(1, r));
        } catch (Exception e) {
//            throw new RuntimeException(e);
            return "";
        }

    }




}
